//remember to use __int128
#include<bits/stdc++.h>
using namespace std;
struct ios{
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x){
        static char ch,sgn; ch = gc(), sgn = 0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}io;
#define cin io
void Print(__int128 x)
{
	if(x > 9)
		Print(x / 10);
	printf("%d",(int)(x % 10));
}
mt19937 Rnd(time(0));
typedef struct{
	int key,ls,rs;
	int len,siz;
	bool rev;
	long long k;
	__int128 b;
	long long tagk;
	__int128 tagb;
}Tree;
Tree t[2000011];
int idx,rot;
inline void pushup(int p)
{
	t[p].siz = t[t[p].ls].siz + t[p].len + t[t[p].rs].siz;
}
inline void Rev(int p)
{
	if(!p) return;
	t[p].b = t[p].b + ((__int128)t[p].k) * t[p].len;
	t[p].k = -t[p].k;
	t[p].tagb = t[p].tagb + ((__int128)t[p].tagk) * t[p].siz;
	t[p].tagk = -t[p].tagk;
	swap(t[p].ls,t[p].rs);
	t[p].rev ^= 1;
}
inline void Add(int p,long long k,__int128 b)
{
	t[p].k += k,t[p].b += b + ((__int128)k) * t[t[p].ls].siz,t[p].tagk += k,t[p].tagb += b;
}
inline void pushdown(int p)
{
	if(t[p].rev)
		Rev(t[p].ls),Rev(t[p].rs),t[p].rev = 0;
	Add(t[p].ls,t[p].tagk,t[p].tagb),Add(t[p].rs,t[p].tagk,t[p].tagb + ((__int128)t[p].tagk) * (t[p].siz - t[t[p].rs].siz)),t[p].tagk = t[p].tagb = 0;
}
int merge(int x,int y)
{
	if(!x || !y) return x | y;
	if(t[x].key < t[y].key)
		return pushdown(x),t[x].rs = merge(t[x].rs,y),pushup(x),x;
	return pushdown(y),t[y].ls = merge(x,t[y].ls),pushup(y),y;
}
inline void Cut(int p,int k)
{
	t[p].len = t[p].siz = k,t[p].rs = 0,pushup(p);
}
void split(int p,int k,int& l)
{
	if(!p) return l = 0,void();
	pushdown(p);
	if(t[t[p].ls].siz >= k)
		return split(t[p].ls,k,l);
	if(t[t[p].ls].siz + t[p].len >= k)
		return l = p,Cut(p,k - t[t[p].ls].siz);
	return l = p,split(t[p].rs,k - t[t[p].ls].siz - t[p].len,t[p].rs),pushup(p);
}
void split_k(int p,long long k,int& l)
{
	if(!p) return l = 0,void();
	pushdown(p);
	if(t[p].k + k >= 0)
		return l = p,split_k(t[p].rs,k,t[p].rs),pushup(p);
	return split_k(t[p].ls,k,l);
}
__int128 qrymx(int p)
{
	if(!t[p].rs) return t[p].b + ((__int128)t[p].k) * t[p].len;
	return pushdown(p),qrymx(t[p].rs);
}
long long w[2000011];
int a[2000011],b[1000011];
long long s[1000011];
int tid,T;
int n,m;
int main()
{
	freopen("festival.in","r",stdin);
	freopen("festival.out","w",stdout);
	cin >> tid >> T;
	while(T--)
	{
		cin >> n >> m;
		for(int i = 2;i <= n;i++)
			cin >> a[i];
		for(int i = 1;i <= m;i++)
			cin >> b[i];
		for(int i = 1;i <= m;i++)
			s[i] = s[i - 1] + b[i];
		for(int i = 1;i <= m;i++)
			w[i] = s[i];
		for(int i = m + 1;i < n - m + 1;i++)
			w[i] = s[m];
		for(int i = n - m + 1;i <= n;i++)
			w[i] = s[m] - s[i - (n - m + 1)];
		t[rot = idx = 1] = {(int)Rnd(),0,0,a[2],a[2],0,w[1],0,0,0};
		for(int i = 2;i <= n;i++)
		{
			split(rot,a[i],rot);
			__int128 mx = qrymx(rot);
			if(t[rot].siz < a[i])
			{
				t[++idx] = {(int)Rnd(),0,0,a[i] - t[rot].siz,a[i] - t[rot].siz,0,0,mx,0,0};
				rot = merge(rot,idx);
			}
			Rev(rot);
			split_k(rot,w[i],rot);
			Add(rot,w[i],0);
			if(!rot)
				t[rot = idx = 1] = {(int)Rnd(),0,0,a[i],a[i],0,0,mx,0,0};
		}
		Print(qrymx(rot));
		printf("\n");
	}
	return 0;
}